package cn.tedu.micro.demo.device.service.impl;

import cn.tedu.micro.demo.common.vo.GunInfoVO;
import cn.tedu.micro.demo.device.dao.mapper.GunInfoMapper;
import cn.tedu.micro.demo.device.dao.repository.DeviceRepository;
import cn.tedu.micro.demo.device.po.GunInfoPO;
import cn.tedu.micro.demo.device.service.DeviceService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Slf4j
@Service
public class DeviceServiceImpl implements DeviceService {
    /*@Autowired
    private GunInfoMapper gunInfoMapper;*/
    @Autowired
    private DeviceRepository DeviceRepository;
    @Override
    public GunInfoVO checkGunStatus(Integer id) {
        GunInfoVO vo=null;
        //GunInfoPO po = gunInfoMapper.selectById(id);
        GunInfoPO po=DeviceRepository.getGunById(id);
        if(po!=null){
            log.info("找到id为{}的枪支",id);
            vo=new GunInfoVO();
            BeanUtils.copyProperties(po,vo);
        }else{
            log.info("没有找到id为{}的枪支",id);
        }
        return vo;
    }
}
